package com.learning.jquizenglish.screen;

import java.util.ArrayList;

import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;

import com.learning.jquizenglish.R;
import com.learning.jquizenglish.common.JQuizEnglishFragment;
import com.learning.jquizenglish.model.DoQuizSession;
import com.learning.jquizenglish.model.QuestionModel;
import com.learning.jquizenglish.screen.viewcontroller.DoQuizView;
import com.learning.jquizenglish.screen.viewcontroller.QuestionNumberView;
import com.learning.jquizenglish.screen.viewcontroller.ResultQuizView;

public class DoQuizScreen extends JQuizEnglishFragment{

	private QuestionNumberView 	mQuestionNumberView;
	private DoQuizView 			mDoQuizView;
	private ResultQuizView 		mResultQuizView;
	private View parentView;
	@Override
	protected View onCreateContentView(LayoutInflater inflater,
			ViewGroup container) {
		parentView = inflater.inflate(R.layout.screen_do_quiz, container, false);
		mQuestionNumberView = new QuestionNumberView(this);
		mDoQuizView			= new DoQuizView(this);
		mResultQuizView		= new ResultQuizView(this);
		changeMode(DoQuizMode.CHOOSE_QUESTION_NUMBER);
		return parentView;
	}
	
	public void changeMode(DoQuizMode mode){
		switch (mode) {
		case CHOOSE_QUESTION_NUMBER:
			parentView.findViewById(R.id.layout_choose_question).setVisibility(View.VISIBLE);
			parentView.findViewById(R.id.layout_do_quiz).setVisibility(View.GONE);
			parentView.findViewById(R.id.layout_result).setVisibility(View.GONE);
			mQuestionNumberView.init(getActivity(), parentView.findViewById(R.id.layout_choose_question));
			break;
		case DO_QUIZ:
			parentView.findViewById(R.id.layout_choose_question).setVisibility(View.GONE);
			parentView.findViewById(R.id.layout_do_quiz).setVisibility(View.VISIBLE);
			parentView.findViewById(R.id.layout_result).setVisibility(View.GONE);
			mDoQuizView.init(getActivity(), parentView.findViewById(R.id.layout_do_quiz));
			break;
		case RESULT:
			parentView.findViewById(R.id.layout_choose_question).setVisibility(View.GONE);
			parentView.findViewById(R.id.layout_do_quiz).setVisibility(View.GONE);
			parentView.findViewById(R.id.layout_result).setVisibility(View.VISIBLE);
			mResultQuizView.init(getActivity(), parentView.findViewById(R.id.layout_result));
			break;
		default:
			break;
		}
	}
	
	public enum DoQuizMode{
		CHOOSE_QUESTION_NUMBER,
		DO_QUIZ,
		RESULT
	}
	
	@Override
	public void onDestroy() {
		DoQuizSession.getInstance().clearSession();
		super.onDestroy();
	}
}
